package com.achievo.know.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import com.achievo.know.component.impl.FileManagerConfig;
import com.dayatang.domain.BaseEntity;
import com.dayatang.domain.InstanceFactory;

@Entity
@Table(name="RAMS_TEMP_ATTACHMENT")
public class TempAttachment extends BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3151273970080801687L;
	
	//唯一标识
	@NotNull
	@Column(name="GUID",length=32,nullable=false)
	private String guid;
	
	//是否可下载
	@Column(name="CAN_DOWN")
	private boolean canDown;
	
	//是否可评议
	@Column(name="CAN_FAQ")
	private boolean canFaq;

	//附件标题
	@NotNull
	@Column(name="ATTACH_NAME",length=500,nullable=false)
	private String attachName;
	
	//附件路径
	@NotNull
	@Column(name="ATTACH_PATH",length=100,nullable=false)
	private String attachPath;
	
	//附件大小
	@Column(name="ATTACH_SIZE",length=3)
	private int attachSize;
	
	//附件类型
	@Column(name="ATTACH_TYPE",nullable=false,length=32)
	private String attachType;
	
	@Column(name="TEMP_FILE_ID",nullable=false,length=32)
	private String tempFileId;
	
	@Column(name="CHECK_SUM")
	private long checkSum;
	
	@Transient
	private java.io.File file;
	
	@Transient
	private String canFaqStr;
	@Transient
	private String canDownStr;
	
	@Column(name="FK_TYPE",nullable=false)
	private int fkType;
	
	
	
	public int getFkType() {
		return fkType;
	}

	public void setFkType(int fkType) {
		this.fkType = fkType;
	}

	public String getCanFaqStr() {
		return canFaqStr;
	}

	public void setCanFaqStr(String canFaqStr) {
		this.canFaqStr = canFaqStr;
	}

	public String getCanDownStr() {
		return canDownStr;
	}

	public void setCanDownStr(String canDownStr) {
		this.canDownStr = canDownStr;
	}

	public boolean isCanFaq() {
		return canFaq;
	}

	public void setCanFaq(boolean canFaq) {
		this.canFaq = canFaq;
	}

	public boolean isCanDown() {
		return canDown;
	}

	public void setCanDown(boolean canDown) {
		this.canDown = canDown;
	}

	public long getCheckSum() {
		return checkSum;
	}

	public void setCheckSum(long checkSum) {
		this.checkSum = checkSum;
	}

	public String getGuid() {
		return guid;
	}

	public void setGuid(String guid) {
		this.guid = guid;
	}

	public String getAttachName() {
		return attachName;
	}

	public void setAttachName(String attachName) {
		this.attachName = attachName;
	}

	public String getAttachPath() {
		return attachPath;
	}

	public void setAttachPath(String attachPath) {
		this.attachPath = attachPath;
	}

	public int getAttachSize() {
		return attachSize;
	}

	public void setAttachSize(int attachSize) {
		this.attachSize = attachSize;
	}



	public String getAttachType() {
		return attachType;
	}

	public void setAttachType(String attachType) {
		this.attachType = attachType;
	}

	@Override
	public boolean equals(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}

	public String getTempFileId() {
		return tempFileId;
	}

	public void setTempFileId(String tempFileId) {
		this.tempFileId = tempFileId;
	}

	public java.io.File getFile() {
		return file;
	}

	public void setFile(java.io.File file) {
		this.file = file;
	}
	
	private static FileManagerConfig config;
	
	public static FileManagerConfig getConfig() {
		if (config == null) {
			config = InstanceFactory.getInstance(FileManagerConfig.class);
		}
		return config;
	}
	
	@Transient
	public String getUploadPath(){
		return getConfig().getMappingIp()+getConfig().getPathUpload()+this.getAttachPath()+this.getGuid()+"."+this.getAttachType();
	}

	
}
